package lenfs.util;

import java.io.File;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class FileDescriptor {

	private final File file;
	private ReadWriteLock lock;

	public FileDescriptor(final File file) {
		this.file = file;
		this.lock = new ReentrantReadWriteLock();
	}

	public File getFile() {
		return file;
	}

	public void readLock() {
		lock.readLock().lock();
	}

	public void readUnlock() {
		lock.readLock().unlock();
	}

	public void writeLock() {
		lock.writeLock().lock();
	}

	public void writeUnlock() {
		lock.writeLock().unlock();
	}

	public int hashCode() {
		return file.hashCode();
	}

	public boolean equals(final Object o) {
		return file.equals(o);
	}
}
